package com.qf.controller;


import com.qf.pojo.DtsUser;
import com.qf.service.GoodsService;
import com.qf.service.OrderService;
import com.qf.service.UserService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.DataOutput;
import java.util.*;

@RestController
@RequestMapping("/admin/stat")
public class UserController {
    @Autowired
    UserService userService;

    @Autowired
    OrderService orderService;

    @Autowired
    GoodsService goodsService;

    @RequestMapping("/user")
    public Object getUser() {

        Map<String,Object> data = new HashMap<>();

        List<Map<String,Object>> userList = userService.getUser();

        List<String> list = new ArrayList<>();
        list.add("day");
        list.add("users");

        data.put("columns",list);
        data.put("rows",userList);
        return ResponseUtil.ok(data);
    }

    @RequestMapping("/order")
    public Object getOrder(){

        Map<String,Object> data = new HashMap<>();
        List<String> list = new ArrayList<>();
        list.add("day");
        list.add("orders");
        list.add("customers");
        list.add("amount");
        list.add("prc");

        List<Map<String,Object>> map = orderService.select();

        System.out.println(map);

        data.put("columns",list);
        data.put("rows",map);
        return ResponseUtil.ok(data);
    }

    @RequestMapping("/goods")
    public Object getGoods(){
        Map<String,Object> data = new HashMap<>();

        List<String> list = new ArrayList<>();
        list.add("day");
        list.add("orders");
        list.add("products");
        list.add("amount");

        List<Map<String,Object>> map = goodsService.select();

                data.put("columns",list);
                data.put("rows",map);
                return ResponseUtil.ok(data);
    }
























}
